package viewmodel

import android.util.Log
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.launch
import java.lang.Exception

typealias vmBLOCK = suspend () -> Unit

open class BaseVideModel: ViewModel() {

    fun launch(block:vmBLOCK){
        viewModelScope.launch {
                try {
                  block.invoke()
                }catch (e: Exception){
                    onError(e)
                }
        }
    }
    private fun onError(e: Exception) {
        Log.d("onError", "onError: $e")
    }
}